package dr.incomeapp.view;

import java.util.LinkedList;
import java.util.List;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import dr.incomeapp.bean.IncomeBean;
import dr.incomeapp.view.miniView.IncomeMiniView;

public class ListRowAdapterSearch extends BaseAdapter {

	Activity context;
	protected List<View> listItem = new LinkedList<View>();;
	protected List<Integer> listItemSeperatorPosition;
	
	protected MyView titleView = null;
	
	public void setTitleView(MyView myView){
		titleView = myView;
	}

	public ListRowAdapterSearch(Activity context) {
		this.context = context;
		this.listItemSeperatorPosition = new LinkedList<Integer>();
	}

	public void addItem(IncomeMiniView listRow) {
		listItem.add(listRow);
	}

	public void addItem(IncomeBean income) {
		addItem(new IncomeMiniView(context, income));
	}

	public void addItemSeperator(MyView listRow) {
		listItemSeperatorPosition.add(listItem.size());
		listItem.add(listRow);
	}

	public boolean isItemSeperator(int position) {
		return listItemSeperatorPosition.contains(position);
	}

	@Override
	public int getItemViewType(int position) {
		return super.getItemViewType(position);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		/*
		if(position == 0){
			if(titleView != null){
				return titleView;
			}
		}
		*/
		//return listItem.get(position-1);
		
		return listItem.get(position);
	}

	public void setList(List<IncomeBean> list) {
		listItem.clear();
		
		
		for (IncomeBean joke : list) {
			addItem(joke);
		}

	}

	public int getCount() {
		return listItem.size();
	}

	public Object getItem(int position) {
		return listItem.get(position);
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public void addEndItem(OneLineView oneLineView) {
		// TODO Auto-generated method stub
		listItem.add(oneLineView);
	}

}
